<?php
/**
 * Created by PhpStorm.
 * User: tom_xia
 * Date: 2018/8/10
 * Time: 17:50
 * 系统素材排行列表
 */
require_once dirname(__DIR__) . "/common.php";


use app\cls\tom\Response;
use app\cls\tom\SysResource;

$key = REDIS_PREFIX."sys_material_list_recommend";
$redis = SysResource::getRedis();
$data = $redis->get($key);
if($data){
    $data = json_decode($data,true);
}else{
    $db = SysResource::getDB(false);
    $db->select("material_id,video_name,time_length,share,dub_number,pic");
    $db->from("video");
    $db->where(["type"=>2,"status"=>1,"is_recommend"=>1]);
    $db->order_by(["order_num"=>"desc"]);
    $query = $db->get();
    $data = $query->all();
    $redis->setEx($key,60,json_encode($data));
}
Response::output(0,"获取数据成功",$data);